import {
  q as o,
  p as V,
  ap as D,
  X as m,
  f as M,
  H as R,
  av as v,
  aw as A,
  az as N,
  as as n,
  aG as O,
  at as h
} from "./index-b50e6ef9.js";
import { f as y } from "./finance-81050a55.js";
function F(b) {
  const c = o([]),
    a = o(!0);
  o({}), V();
  const g = o(1),
    u = o(10),
    x = D("reload"),
    d = m({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    w = m({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    B = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "id", minWidth: 50 },
      { label: "用户名", prop: "user_name", minWidth: 80 },
      { label: "手机号", prop: "user_phone", minWidth: 100 },
      {
        label: "升级前级别",
        prop: "old_vip",
        minWidth: 80,
        formatter: ({ old_vip: e }) => {
          if (e == 0) return "普通会员";
          if (e == 1) return "VIP会员";
        }
      },
      {
        label: "升级后级别",
        prop: "new_vip",
        minWidth: 80,
        formatter: ({ new_vip: e }) => {
          if (e == 0) return "普通会员";
          if (e == 1) return "VIP会员";
        }
      },
      { label: "备注", prop: "content", minWidth: 80 },
      { label: "创建时间", prop: "create_time", minWidth: 100 }
    ],
    C = M(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function I(e) {
    N(e);
  }
  async function S(e) {
    const s = { role_id: e.role_id },
      i = JSON.stringify(s),
      r = { value: n.enc.Base64.stringify(n.enc.Utf8.parse(i)) },
      t = await O(r);
    t.code == 200
      ? (h("删除成功", { type: "success" }), x())
      : h(t.msg, { type: "error" });
  }
  function W() {}
  function J(e) {
    (u.value = e), p(void 0, e);
  }
  function _(e) {
    (g.value = e), p(e, void 0);
  }
  function z(e) {}
  function U(e) {
    (w.text = `正在加载第${e}页...`),
      (a.value = !0),
      v(600).then(() => {
        a.value = !1;
      });
  }
  async function k(e) {
    a.value = !0;
    const s = {
        page: 1,
        pagesize: u.value,
        content: "vip",
        user_phone: e.user_phone,
        type: e.type
      },
      i = JSON.stringify(s),
      r = { value: n.enc.Base64.stringify(n.enc.Utf8.parse(i)) },
      { data: t } = await y(r);
    (c.value = t.vip.data),
      (d.total = t.vip.total),
      setTimeout(() => {
        a.value = !1;
      }, 500);
  }
  async function p(e = g.value, s = u.value) {
    const f = JSON.stringify({ page: e, pagesize: s, content: "vip" }),
      t = { value: n.enc.Base64.stringify(n.enc.Utf8.parse(f)) },
      l = await y(t);
    l.code === 200
      ? ((c.value = l.data.vip.data),
        (d.total = l.data.vip.total),
        setTimeout(() => {
          a.value = !1;
        }, 500))
      : h(l.msg, { type: "error" });
  }
  const L = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    R(() => {
      v().then(() => {
        const { setWatermark: e } = A(b.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        p();
    }),
    {
      loading: a,
      columns: B,
      dataList: c,
      pagination: d,
      buttonClass: C,
      onSearch: k,
      resetForm: L,
      handleaddUser: W,
      handleUpdate: I,
      handleDelete: S,
      handleSizeChange: J,
      handleCurrentChange: _,
      handleSelectionChange: z,
      onCurrentChange: U
    }
  );
}
export { F as useRole };
